package com.starhub.web.host.impl;

import java.util.Arrays;
import java.util.List;

import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;

import com.starhub.web.host.CategoryHost;
import com.starhub.web.host.StarHubBaseHost;
import com.starhub.web.model.Category;

public class CategoryHostImpl extends StarHubBaseHost implements CategoryHost {

	private RestTemplate restTemplate;
	
	public List<Category> getHeaderCategories() {
		ResponseEntity<Category[]> response = restTemplate.getForEntity("http://localhost:8080/StarHub/getHeaderCategories", Category[].class);
		return Arrays.asList(response.getBody());
	}
	
	public List<Category> getFooterCategories() {
		ResponseEntity<Category[]> response = restTemplate.getForEntity("http://localhost:8080/StarHub/getFooterCategories", Category[].class);
		return Arrays.asList(response.getBody());
	}

	public void setRestTemplate(RestTemplate restTemplate) {
		this.restTemplate = restTemplate;
	}
}
